-- @Author: 作者QQ201878826
-- @Date:   2022-04-25 08:30:01
-- @Last Modified by:   作者QQ381990860
-- @Last Modified time: 2022-09-18 22:48:54

local 商店道具 ={
    --飞儿
    [0]={"包子"},
    --0级武器
    [1]={"折扇","红缨枪","牛皮鞭","曲柳杖","铁爪","松木锤","琉璃珠","双短剑","青铜短剑","柳叶刀","青铜斧","五色缎带","黄铜圈","硬木弓","细木棒","钝铁重剑","素纸灯","油纸伞"},
    --10级武器
    [2]={"铁骨扇","曲尖枪","牛筋鞭","红木杖","天狼爪","镔铁锤","水晶珠","镔铁双剑","铁齿剑","苗刀","开山斧","幻彩银纱","精钢日月圈","铁胆弓","金丝魔棒","桃印铁刃","竹骨灯","红罗伞"},
    --20级武器
    [3]={"精钢扇","锯齿矛","乌龙鞭","白椴杖","幽冥鬼爪","八棱金瓜","珍宝珠","龙凤双剑","吴越剑","夜魔弯刀","双面斧","金丝彩带","离情环","紫檀弓","玉如意","赭石巨剑","红灯笼","紫竹伞"},
    --30级武器
    [4]={"铁面扇","乌金三叉戟","钢结鞭","墨铁拐","青龙牙","狼牙锤","翡翠珠","竹节双剑","青锋剑","金背大砍刀","双弦钺","无极丝","金刺轮","宝雕长弓","点金棒","壁玉长铗","鲤鱼灯","锦绣椎"},
    --40级武器
    [5]={"百折扇","火焰枪","蛇骨鞭","玄铁牛角杖","勾魂爪","烈焰锤","莲华珠","狼牙双剑","龙泉剑","雁翅刀","精钢禅钺","天蚕丝带","风火圈","錾金宝弓","云龙棒","青铜古剑","芙蓉花灯","幽兰帐"},
    --长安防具
    [6]={"方巾","簪子","布衣","布裙","布鞋","面具","梅花簪子","鳞甲","五彩裙","马靴","羊角盔","媚狐头饰","钢甲","金缕羽衣","绿靴"},
    --长安饰品
    [7]={"银腰带","珍珠链","腰带","护身符","乱牙咬","魔童大牙","高速之星","荧光坠子"},
    --傲来防具
    [8]={"纶巾","珍珠头带","水晶腰带","侠客履","龙鳞羽衣","玉树腰带","锁子甲","骷髅吊坠","苍魂珠"},
    --建业防具
    [9]={"方巾","簪子","布衣","布裙","布鞋","护身符","腰带","布帽","玉钗","皮衣","丝绸长裙","牛皮靴","五色飞石","缎带"},
    --傲来药店
    [10]={"天不老","紫石英","鹿茸","六道轮回","凤凰尾","孔雀红","硫磺草","龙之心屑","火凤之睛","月星子","仙狐涎","地狱灵芝","血珊瑚","餐风饮露","白露为霜","天龙水"},
    --长寿防具
    [11]={"九宫坠","白面狼牙","江湖夜雨","凤头钗","缨络丝带","神行靴","琥珀腰链","紧身衣","天香披肩"},
    --杂货店
    [12]={"摄妖香","洞冥草"},
    --罗道人
    [13]={"飞行符","白色导标旗","红色导标旗","黄色导标旗","蓝色导标旗","绿色导标旗","白色合成旗","红色合成旗","黄色合成旗","蓝色合成旗","绿色合成旗"},
    --建业药店
    [14]={"四叶花","紫丹罗","血色茶花","熊胆","丁香水","麝香","金创药","佛光舍利子","佛手","灵脂","曼佗罗花","白玉骨头","天青地白"},
    --酒店老板
    [15]={"包子","秘制红罗羹"},
    --50级武器
    [16]={"墨杆金钩","黄金钺","黄金剑","鱼骨双剑","云龙绸带","玄冰刺","劈水扇","幽路引魂","破甲战锤","玉竹金铃","赤炎环","破天宝刀","金错巨刃","琳琅盖","如意宫灯","夜灵珠","鹰眼法杖","玉腰弯弓"},
}
local 灵饰类型= {"手镯","佩饰","戒指","耳饰"}
local 商店处理类 =class()
function 商店处理类:初始化( )
self.ShopGroup={}
  for n=0,16 do
    self.ShopGroup[n]={}
    for i=1,#商店道具[n] do
       self.ShopGroup[n][i]=AddItem(商店道具[n][i])
    end
  end
    --宝石商人
    self.ShopGroup[17]={
    AddItem("召唤兽内丹",nil,"随机技能",nil,8000000),
    AddItem("易经丹",nil,nil,nil,45000000),
    AddItem("清灵净瓶",nil,nil,nil,25000000),
    AddItem("玉葫灵髓",nil,nil,nil,25000000),
    -- AddItem("红宝石",1,nil,nil,100000),
    -- AddItem("绿宝石",1,nil,nil,100000),
    -- AddItem("蓝宝石",1,nil,nil,100000),
    -- AddItem("黄宝石",1,nil,nil,100000),
    AddItem("光芒石",1,nil,nil,100000),
    AddItem("月亮石",1,nil,nil,100000),
    AddItem("太阳石",1,nil,nil,100000),
    AddItem("舍利子",1,nil,nil,100000),
    AddItem("红玛瑙",1,nil,nil,100000),
    AddItem("黑宝石",1,nil,nil,100000),
    AddItem("神秘石",1,nil,nil,100000),
    }


    --袁天罡
   self.ShopGroup[30]={}
        local 灵饰序号 = 0
        for i=1,3 do
        for o=1,4 do
        灵饰序号 = 灵饰序号 +1
        self.ShopGroup[30][灵饰序号]=AddItem("灵饰指南书",(i*2+4)*10,灵饰类型[o],nil,12000000*2^(i-1))
        end
        end
   self.ShopGroup[31]={}
        local 灵饰序号 = 0
        for i=4,6 do
        for o=1,4 do
        灵饰序号 = 灵饰序号 +1
        self.ShopGroup[31][灵饰序号]=AddItem("灵饰指南书",(i*2+4)*10,灵饰类型[o],nil,12000000*2^(i-1))
        end
        end
    self.ShopGroup[32]={}
        for i=1,6 do
            self.ShopGroup[32][i]=AddItem("元灵晶石",(i*2+4)*10,nil,nil,6000000*2^(i-1))
        end

    --古董商人
    self.ShopGroup[22]={
        AddItem("未鉴定的古董",nil,nil,nil,88888),
        AddItem("考古铁铲",nil,nil,nil,999999)
        }

    --云游道人
    self.ShopGroup[28] = {
        AddItem("高级召唤兽内丹",nil,"随机技能",nil,58000000),
        AddItem("高级魔兽要诀",nil,"随机技能",nil,38888888),
        AddItem("红宝石",3,nil,nil,2000000),
        AddItem("绿宝石",3,nil,nil,2000000),
        AddItem("蓝宝石",3,nil,nil,2000000),
        AddItem("黄宝石",3,nil,nil,2000000),
        AddItem("光芒石",3,nil,nil,2000000),
        AddItem("月亮石",3,nil,nil,2000000),
        AddItem("太阳石",3,nil,nil,2000000),
        AddItem("舍利子",3,nil,nil,2000000),
        AddItem("红玛瑙",3,nil,nil,2000000),
        AddItem("黑宝石",3,nil,nil,2000000),
        AddItem("神秘石",3,nil,nil,2000000),
       }


    self.ShopGroup[40]={
  AddItem("高级召唤兽内丹",nil,"随机技能",nil,50),
  --AddItem("化龙鼎",0,nil,nil,100),
  AddItem("三界密录",0,nil,nil,100),
  AddItem("摸金符",0,nil,nil,500),
  AddItem("固神丹",0,nil,nil,800),
  AddItem("七彩石",0,nil,nil,50),
  AddItem("武器幻色丹",0,nil,nil,50),
  --AddItem("宠物造型药水",0,nil,nil,300),
  AddItem("特技符",nil,nil,nil,1000),
  --AddItem("150双加120礼包",0,nil,nil,800),
  --AddItem("160双加120礼包",0,nil,nil,1500),
--  AddItem("160双加100整套礼包",nil,nil,nil,3000),
  AddItem("特殊魔兽要诀",nil,"随机技能",nil,1000),
 }
    self.ShopGroup[39] = {
        {名称="绿色合成旗",地图="长寿村",坐标={[1]={y=179,x=131},[2]={y=125,x=135},[3]={y=102,x=109},[4]={y=132,x=35},[5]={y=48,x=44},[6]={y=86,x=99},[7]={y=22,x=105}},次数=140,价格=60000,编号=1070,类型="合成旗",地图编号=1070},
  {名称="黄色合成旗",地图="傲来国",坐标={[2]={y=10,x=212},[5]={y=56,x=29},[3]={y=131,x=173},[7]={y=26,x=63},[1]={y=49,x=122},[4]={y=122,x=50},[6]={y=11,x=10}},次数=140,价格=60000,编号=1092,类型="合成旗",地图编号=1092},
  {名称="红色合成旗",地图="长安城",坐标={[2]={y=241,x=281},[5]={y=117,x=459},[3]={y=139,x=497},[7]={y=275,x=9},[1]={y=114,x=219},[4]={y=35,x=442},[6]={y=274,x=507}},次数=140,价格=60000,编号=1001,类型="合成旗",地图编号=1001},
  {名称="蓝色合成旗",地图="大唐境外",坐标={[1]={y=65,x=10},[2]={y=55,x=49},[3]={y=21,x=18},[4]={y=13,x=63},[5]={y=14,x=222},[6]={y=11,x=534},[7]={y=45,x=627}},次数=140,价格=60000,编号=1173,类型="合成旗",地图编号=1173},
  {名称="白色合成旗",地图="朱紫国",坐标={[1]={y=26,x=140},[2]={y=24,x=17},[3]={y=111,x=14},[4]={y=100,x=61},[5]={y=109,x=145},[6]={y=64,x=94},[7]={y=52,x=160}},次数=140,价格=60000,编号=1208,类型="合成旗",地图编号=1208},
  {名称="红色合成旗",地图="长安城",坐标={[1]={y=6,x=311},[2]={y=10,x=496},[3]={y=206,x=344},[4]={y=206,x=344},[5]={y=206,x=344},[6]={y=206,x=344},[7]={y=206,x=344}},次数=100,价格=300000,编号=1208,类型="合成旗",地图编号=1001},
  {名称="蓝色合成旗",地图="大唐境外",坐标={[1]={y=45,x=627},[2]={y=8,x=533},[3]={y=10,x=60},[4]={y=68,x=9},[5]={y=93,x=17},[6]={y=104,x=46},[7]={y=111,x=188}},次数=100,价格=300000,编号=1173,类型="合成旗",地图编号=1173},
  {名称="白色合成旗",地图="大唐国境",坐标={[1]={y=73,x=180},[2]={y=11,x=44},[3]={y=267,x=234},[4]={y=267,x=234},[5]={y=267,x=234},[6]={y=267,x=234},[7]={y=267,x=234}},次数=100,价格=300000,编号=1110,类型="合成旗",地图编号=1110},
--AddItem("副宠升级丹",0,nil,nil,1000),
}

    --春节商城
    self.ShopGroup[50] = {
        AddItem("天机培元丹",nil,nil,nil,1000000,nil),
        AddItem("九霄清心丸",nil,nil,nil,1000000,nil),
        }
end
function 商店处理类:GetNpcShop(id, 序号)
  self.发送消息 = {}
  序号 = 序号 + 0
  self.ShopGroup[序号].银子 = 0
  self.ShopGroup[序号].组号 = 序号
  self.ShopGroup[序号].银子 = 玩家数据[id].角色.道具.货币.银子
  发送数据(玩家数据[id].连接id, 9001, self.ShopGroup[序号])
end
function 商店处理类:GetNpcShop1(id, 序号)
  self.发送消息 = {}
  序号 = 序号 + 0
  self.ShopGroup[序号].银子 = 0
  self.ShopGroup[序号].组号 = 序号
  self.ShopGroup[序号].银子 = 玩家数据[id].角色.镇魔声望.当前
  发送数据(玩家数据[id].连接id, 9001, self.ShopGroup[序号])
end
function 商店处理类:数据处理(user,parameter,number,text,Value)
  if number == 1 then
     self:GetShopData(user,parameter,text)
  elseif  number == 2 then
    self:buy(user,parameter,text)
   elseif  number == 3 then
    self:NPCbuy(user,parameter,text,Value)
  end
end
local  GetMoneyForm =function(user,text)
    local money,age
   if text =="银子" then -- 活动积分
        money=user.角色.道具.货币.银子
        age ="银子"
     elseif text =="杂货" then -- 活动积分
        money=user.角色.道具.货币.银子
        age ="银子"
     elseif text =="符石" then -- 活动积分
        money=user.角色.道具.货币.银子
        age ="银子"
    elseif text =="活动积分" then -- 活动积分
        money=user.角色.活动积分
        age ="活动积分"
    elseif text =="比武积分" then -- 比武积分
       money=user.角色.比武积分
       age ="比武积分"
    elseif text =="副本积分" then -- 副本积分
       money=user.角色.副本积分
       age ="副本积分"
    elseif text =="地煞积分" then -- 神器积分
        money=user.角色.地煞积分
         age ="地煞积分"
    elseif text =="知了积分" then -- 知了积分
        age ="知了积分"
        money=user.角色.知了积分
    elseif text =="天罡积分" then -- 天罡积分
        age ="天罡积分"
        money=user.角色.天罡积分
    elseif text =="单人积分" then -- 单人积分
        age ="单人积分"
        money=user.角色.单人积分
    elseif text =="成就积分" then -- 成就积分
        age ="成就积分"
        money=user.角色.成就积分
    elseif text =="特殊积分" then -- 特殊积分
        age ="特殊积分"
        money=user.角色.特殊积分
    elseif text =="活跃度" then -- 活动积分
        age ="活跃度"
        money=user.角色.活跃度
 elseif text =="守护九宠" then -- 活动积分
        age ="守护九宠"
        money=f函数.读配置(ServerDirectory.."玩家信息/账号" .. user.账号 .. "/账号.txt", "账号信息", "守护九宠") + 0

   elseif text =="点卡" then -- 活动积分
        age ="点卡"
        money=f函数.读配置(ServerDirectory.."玩家信息/账号" .. user.账号 .. "/账号.txt", "账号信息", "点卡") + 0

    else
        money= f函数.读配置(ServerDirectory.."玩家信息/账号" .. user.账号 .. "/账号.txt", "账号信息", "仙玉") + 0
        age ="仙玉"
    end
    return money,age
end
function 商店处理类:GetShopData(user,min,text)
  if not merchandise[text] or min < 1 then
     print(string.format("玩家ID%d请求一个错误的商城组%s",user.id,text))
     return
  elseif   min> #merchandise[text] then
    发送数据(user.连接id,7,"#Y/已经是最后一页了")
    return
  end
    local age ={}
    local delcount= (text=="锦衣" or text=="光环" or text=="脚印" or text=="祥瑞" or text=="定制"or text=="传音" or text=="战锦"or text=="翅膀"or text=="头像" or text=="彩饰") and  20 or  32

    local del= text=="召唤兽" and 12 or delcount
    for i=1,del do
        if  merchandise[text][i+min-1] then
         age[i] =ShopData[merchandise[text][i+min-1]]
         age[i].number =merchandise[text][i+min-1]
        else
         break
       end
    end
    age.银子 =GetMoneyForm(user,text)
    age.ID =text
    age.min =min
     if text=="活跃度" then
         发送数据(user.连接id,20056,age)
     else
        发送数据(user.连接id,20034,age)
     end
  end
function 商店处理类:buy(user,number,text)
   local  count =assert(tonumber(text),"商城传入的数量错误"..text)
   count= math.floor(count) ---防止小数点 网关已经加过检测 所以可以屏蔽
   if not ShopData[number] then
       __S服务:输出(string.format("ID%s为传入一个错误商品编号%s",user.id,number))
       return
   elseif count < 1 then
        return
   end
     local  money,age =GetMoneyForm(user,ShopData[number].分类)
    local  Cyclevalue = ShopData[number].数量 and 1 or count
     local  TempCount =  ShopData[number].数量 and count or 1
    for i=1,Cyclevalue do
       if  money < ShopData[number].价格*TempCount  and  ShopData[number].分类 ~= "头像" and  ShopData[number].分类 ~= "彩饰"  then
           发送数据(user.连接id,7,string.format("#Y/您的%s不足",age))
           return
       elseif  ShopData[number].分类 =="召唤兽" then
            if  #user.召唤兽.数据>= user.召唤兽.数据.召唤兽上限   then
                  发送数据(user.连接id,7,"#Y/召唤兽已经达到上限")
                  return
            end
            if  角色处理类:扣除仙玉(user,ShopData[number].价格,"商城购买"..ShopData[number].名称) then
                 table.insert(user.召唤兽.数据,AddPet(ShopData[number].名称,ShopData[number].类型))
                 user.召唤兽:刷新属性(#user.召唤兽.数据)
            else
                 发送数据(user.连接id,7,"#Y/你没有足够的仙玉！")
                return
            end
       elseif  角色处理类:取可用道具格子(user,"包裹") == 0  and  ShopData[number].分类 ~= "头像" and  ShopData[number].分类 ~= "彩饰"  then
           发送数据(user.连接id, 7, "#Y/您身上似乎没有多余的道具存放空间")
           return
           elseif ShopData[number].类型 == "锦衣" then
            if 角色处理类:取可用道具格子(user,"包裹") == 0 then
               发送数据(user.连接id, 7, "#Y/您身上似乎没有多余的道具存放空间")
               return
            end
            if  角色处理类:扣除仙玉(user,ShopData[number].价格,"商城购买"..ShopData[number].名称) then
              道具处理类:给予道具(user.id,ShopData[number].名称)
            else
                发送数据(user.连接id,7,"#Y/你没有足够的仙玉！")
                return
            end
       elseif  角色处理类:取可用道具格子(user,"包裹") == 0  then
           发送数据(user.连接id, 7, "#Y/您身上似乎没有多余的道具存放空间")
           return
       else
          local  RoseTempID  =角色处理类:取可用道具格子(user,"包裹")
           local  ItemTempID =道具处理类:取道具编号(user.id)
            if  ShopData[number].分类 == "头像" or  ShopData[number].分类 == "彩饰" then

            if 扣除装饰劵(user.id) == false  then
              return
            end
             user.角色[ShopData[number].分类] = ShopData[number].名称
           -- 角色处理类["扣除"..age](角色处理类,user,ShopData[number].价格,"商城")
             --money=money- ShopData[number].价格
             if user.角色[ShopData[number].分类.."时间"]  - os.time() > 0 then
               user.角色[ShopData[number].分类.."时间"] = user.角色[ShopData[number].分类.."时间"] + 2592000
             else
             user.角色[ShopData[number].分类.."时间"] = os.time() + 2592000
            end
             发送数据(user.连接id, 2010, 角色处理类:获取地图数据(user))
            发送数据(user.连接id, 3007,{格子=RoseTempID,数据=user.物品[ItemTempID]})
         else

          user.角色.道具.包裹[RoseTempID] = ItemTempID
           if ShopData[number].技能 and  ShopData[number].技能=="随机技能" then
            user.物品[ItemTempID] = AddItem(ShopData[number].名称,ShopData[number].等级)
           elseif ShopData[number].种类 and  ShopData[number].种类=="随机种类" then
            user.物品[ItemTempID] = AddItem(ShopData[number].名称,ShopData[number].等级)
           elseif ShopData[number].等级 and  ShopData[number].等级==0 then
            user.物品[ItemTempID] = AddItem(ShopData[number].名称,math.random(1,8),ShopData[number].技能)
            elseif ShopData[number].名称 == "百年魂石" or ShopData[number].名称 == "千年魂石" or ShopData[number].名称 == "万年魂石" or ShopData[number].名称 == "十万年魂石" then
             user.物品[ItemTempID] = AddItem(ShopData[number].名称)
           else

            user.物品[ItemTempID] = table.copy(ShopData[number])

           end
            if user.物品[ItemTempID].Time then
                 user.物品[ItemTempID].Time=os.time()+3600*48
            end

            if ShopData[number].数量 then
                  user.物品[ItemTempID].数量  =count
                  角色处理类["扣除"..age](角色处理类,user,ShopData[number].价格*count,"商城")
            else
                  角色处理类["扣除"..age](角色处理类,user,ShopData[number].价格,"商城")
            end

            money=money- ShopData[number].价格
            发送数据(user.连接id, 3007,{格子=RoseTempID,数据=user.物品[ItemTempID]})
       end
    end
    end
    if ShopData[number].分类=="活跃度" then
       发送数据(user.连接id,20057,GetMoneyForm(user,ShopData[number].分类))
    else
      发送数据(user.连接id,20043,GetMoneyForm(user,ShopData[number].分类))
    end

    local Message = string.format("花费了%d点%s购买了%d个%s",ShopData[number].价格*count,age,count,ShopData[number].名称)
        if  ShopData[number].分类 == "头像" or  ShopData[number].分类 =="彩饰"  then

    Message = string.format("花费了%d张%s购买了%d个%s",1,"装饰劵",count,ShopData[number].分类)
    end
    发送数据(user.连接id,7,"#Y/你"..Message)
    if ShopData[number].分类~="银子" then
      广播消息(9,"#jj/#G/"..user.角色.名称.."("..user.id..")#Y/在商城"..Message)
    end
end

function 商店处理类:NPCbuy(user,number,text,Value)
  local  count =assert(tonumber(text),"商城传入的数量错误"..text)
  Value=Value+0
   count= math.floor(count) ---防止小数点 网关已经加过检测 所以可以屏蔽
   if not self.ShopGroup[Value][number] then
       __S服务:输出(string.format("ID%s为传入一个错误商品编号%s",user.id,number))
       return
   elseif count < 1 then
        return
   end

  if Value == 28 then
    if count > 1 then
      发送数据(user.连接id, 7, "#y/本商品不能叠加购买！！")
      return 0
    elseif self.ShopGroup[Value][number].名称 == "高级魔兽要诀" and 道人数据.兽诀 <= 0 then
      发送数据(user.连接id, 7, "#y/这种商品已经卖完了，请在整点的时候再来买")
      return 0

    elseif self.ShopGroup[Value][number].名称 == "高级召唤兽内丹" and 道人数据.内丹 <= 0 then
      发送数据(user.连接id, 7, "#y/这种商品已经卖完了，请在整点的时候再来买")
      return 0

    elseif self.ShopGroup[Value][number].名称 ~= "高级魔兽要诀" and self.ShopGroup[Value][number].名称 ~= "高级召唤兽内丹" and self.ShopGroup[Value][number].名称 ~= "无字天书" and 道人数据.宝石 <= 0 then
      发送数据(user.连接id, 7, "#y/这种商品已经卖完了，请在整点的时候再来买")
      return 0
    end
  end

    local  Cyclevalue = self.ShopGroup[Value][number].数量 and 1 or count
    local  TempCount = self.ShopGroup[Value][number].数量 and count or 1
    for i=1,Cyclevalue do

         if Value == 40 then
         if  user.角色.镇魔声望.当前 < self.ShopGroup[Value][number].价格*TempCount then
           发送数据(user.连接id,7,"#Y/您的镇魔积分不足")
           return
         end
         else
           if  user.角色.道具.货币.银子 < self.ShopGroup[Value][number].价格*TempCount then
           发送数据(user.连接id,7,"#Y/您的银子不足")
           return
         end
        end
       if  角色处理类:取可用道具格子(user,"包裹") == 0 then
           发送数据(user.连接id, 7, "#Y/您身上似乎没有多余的道具存放空间")
           return
       else
           local  RoseTempID  =角色处理类:取可用道具格子(user,"包裹")
           local  ItemTempID =道具处理类:取道具编号(user.id)
          user.角色.道具.包裹[RoseTempID] = ItemTempID

          --  if self.ShopGroup[Value][number].技能 and  self.ShopGroup[Value][number].技能=="随机技能" then
          --   user.物品[ItemTempID] = AddItem(self.ShopGroup[Value][number].名称,self.ShopGroup[Value][number].等级)
          -- elseif self.ShopGroup[Value][number].等级 and  self.ShopGroup[Value][number].等级==0 then
          --   user.物品[ItemTempID] = AddItem(self.ShopGroup[Value][number].名称,math.random(1,8),self.ShopGroup[Value][number].技能)

          --  else
          --   user.物品[ItemTempID] = table.copy(self.ShopGroup[Value][number])
          --  end
           if self.ShopGroup[Value][number].技能 and  (self.ShopGroup[Value][number].技能=="随机技能"  or self.ShopGroup[Value][number].技能=="随机种类") then
            user.物品[ItemTempID] = AddItem(self.ShopGroup[Value][number].名称,self.ShopGroup[Value][number].等级)
          elseif self.ShopGroup[Value][number].种类  and  (self.ShopGroup[Value][number].种类=="随机技能"  or self.ShopGroup[Value][number].种类=="随机种类") then
          --print(22222)
            user.物品[ItemTempID] = AddItem(self.ShopGroup[Value][number].名称,self.ShopGroup[Value][number].等级)
          elseif self.ShopGroup[Value][number].等级 and  self.ShopGroup[Value][number].等级==0 then
            user.物品[ItemTempID] = AddItem(self.ShopGroup[Value][number].名称,math.random(1,7),self.ShopGroup[Value][number].技能)

           else
            user.物品[ItemTempID] = table.copy(self.ShopGroup[Value][number])
           end
          if Value == 28 then
               if user.物品[ItemTempID].名称 == "高级魔兽要诀" then
                self.临时名称 = 取道人兽诀名称()
                广播消息(9, "#jj/#g/ " .. user.角色.名称 .. "#y/在云游道人试试手气处购买了一本#r/" .. self.临时名称 .. "#y/兽诀")
                user.物品[ItemTempID].技能 = self.临时名称
                道人数据.兽诀 = 道人数据.兽诀 - 1

              elseif user.物品[ItemTempID].名称=="高级召唤兽内丹" then
                   self.临时名称=取内丹("高级")
                    广播消息(9,"#jj/#g/ "..user.角色.名称.."#y/云游道人处购买了一颗#r/"..self.临时名称.."#y/内丹")
                         user.物品[ItemTempID].技能=self.临时名称
                      道人数据.内丹 = 道人数据.内丹 - 1

              else
                self.临时名称 = math.random(2, 8)
                广播消息(9, "#jj/#g/ " .. user.角色.名称 .. "#y/在云游道人处购买了一颗#r/" .. self.临时名称 .. "#y/级的" .. self.ShopGroup[Value][number].名称)
                user.物品[ItemTempID].等级 = self.临时名称
                道人数据.宝石 = 道人数据.宝石 - 1
              end
         end
        if user.物品[ItemTempID].名称 == "考古铁铲" then
              local 宝图地图 = {1501,1506,1070,1091,1092,1110,1173,1146,1142,1131,1140,1512,1513,1514,1174}
               user.物品[ItemTempID].地图编号=宝图地图[math.random(1,#宝图地图)]
                local 临时坐标= 地图处理类:Randomloadtion( user.物品[ItemTempID].地图编号)
                 user.物品[ItemTempID].x=临时坐标.x
                 user.物品[ItemTempID].y=临时坐标.y
        end

            if self.ShopGroup[Value][number].数量 then
                   user.物品[ItemTempID].数量  =count
                   if Value == 40 then
                   user.角色.镇魔声望.当前 = user.角色.镇魔声望.当前 - self.ShopGroup[Value][number].价格*count
                   else
                   角色处理类:扣除银子(user,self.ShopGroup[Value][number].价格*count,"商城")
                   end
            else
            if Value == 40 then
               user.角色.镇魔声望.当前 = user.角色.镇魔声望.当前 - self.ShopGroup[Value][number].价格
               else
               角色处理类:扣除银子(user,self.ShopGroup[Value][number].价格,"商城")
               end
            end


            发送数据(user.连接id, 3007,{格子=RoseTempID,数据=user.物品[ItemTempID]})
       end
    end
    local Msg= string.format("#Y/您花费了%d点%s购买了%d个%s",self.ShopGroup[Value][number].价格*count,"银子",count,self.ShopGroup[Value][number].名称)
    if Value == 40 then
    发送数据(user.连接id,9002,user.角色.镇魔声望.当前)
     Msg= string.format("#Y/您花费了%d点%s购买了%d个%s",self.ShopGroup[Value][number].价格*count,"镇魔积分",count,self.ShopGroup[Value][number].名称)
    else
    发送数据(user.连接id,9002,user.角色.道具.货币.银子)
     Msg= string.format("#Y/您花费了%d点%s购买了%d个%s",self.ShopGroup[Value][number].价格*count,"银子",count,self.ShopGroup[Value][number].名称)
    end

    发送数据(user.连接id,7,Msg)
end
return 商店处理类